
l = [1, 3, 5]
print("for 循环如下——")
x = 0
for i in l:
    x += 1
    print (f"第{x}位数字为{i}")

print("while 循环如下——")
y = 0
while y < 3:
    i = l[y]
    y += 1
    print (f"第{y}位数字为{i}")

print("100以内斐波那契数列while循环如下——")
a = 0
b = 1
print(a,b,end=" ")
while True:
    if a+b > 100:
        break
    a, b = b, a+b
    print(b,end=" ")
print()

print("100以内斐波那契数列for循环如下——")
n1 = 0
n2 = 1
print(n1,n2,end=" ")
for i in range(100):
    if n1+n2 > 100:
        break
    n1, n2 = n2, n1+n2
    print(n2, end=" ")
print()

print("calculator自定义异常ParamsError——")
def div(x1,x2):
    try:
        return(x1/x2)
    except ZeroDivisionError:
        raise ParamsError("分母不能为0")
    finally:
        print("function my_sub end")
x1 = int(input("分子为："))
x2 = int(input("分母为："))
result = div(x1,x2)
print (result)